<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>${SYSTEM_NAME}</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${FILE_VERSION}" media="all">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/js/zTree_v3/css/metroStyle/metroStyle.css?v=${FILE_VERSION}" type="text/css">
</head>
<body>
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body" style="padding: 15px;">
		<form class="layui-form" action="${pageContext.request.contextPath}/sys/menu/save" style="width:80%" method="post" id="basicform">
			<input type="hidden" id="id" name="id" autocomplete = "off" value="${menu.id }"/>
		  <div class="layui-form-item">
			  <label class="layui-form-label layui-form-required">父类菜单</label>
			  <div class="layui-input-inline">
				  <input type="hidden" id="parentId" name="parentId" lay-verify="required"
						 value="${menu.parentId == null ? 0 : menu.parentId }" >
				  <input type="text" id="parentName" class="layui-input" lay-verify="required"
						 readonly="readonly" value="${menu.parentName == null ? "顶级节点" : menu.parentName }"
						 placeholder="点击选择父类菜单" onclick="selectMenu()">
			  </div>
			  <div class="layui-input-inline">
				  <button type="button" class="layui-btn layui-btn-primary layui-border-blue" onclick="selectMenu()">点击选择</button>
			  </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label layui-form-required">名称</label>
		    <div class="layui-input-inline">
		      <input type="text" name="name" id="name" lay-verify="required" placeholder="请输入名称" class="layui-input" autocomplete="off" value="${menu.name }">
		    </div>
		    <div class="layui-form-mid layui-word-aux">名称不能为空</div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label layui-form-required">权限</label>
		    <div class="layui-input-inline">
		      <input type="text" name="shiro" placeholder="权限" class="layui-input" lay-verify="required" value="${menu.shiro }">
		    </div>
			  <div class="layui-form-mid layui-word-aux">如 sys:user:list</div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">访问地址</label>
		    <div class="layui-input-inline">
		      <input type="text" name="href" placeholder="请输入访问地址" class="layui-input" autocomplete="off" value="${menu.href }">
		    </div>
			  <div class="layui-form-mid layui-word-aux">如 /sys/user/list</div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">图标</label>
		    <div class="layui-input-inline">
		      <input type="text" id="icon" name="icon" class="layui-input" autocomplete="off" value="${menu.icon }">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label layui-form-required">排序</label>
		    <div class="layui-input-inline">
		      <input type="text" id="sort" lay-verify="number" name="sort" class="layui-input" autocomplete="off"
					 value="${menu.sort == null ? 0 : menu.sort}">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label layui-form-required">是否显示</label>
		    <div class="layui-input-inline">
		    	<select name="isShow">
					<c:forEach items="${isShowMap}" var="t">
						<option value="${t.key }" <c:if test="${t.key eq menu.isShow}">selected="selected"</c:if>>${t.value }</option>
					</c:forEach>
				</select>
		    </div>
		  </div>

			<div class="layui-form-item">
				<label class="layui-form-label layui-form-required">显示方式</label>
				<div class="layui-input-inline">
					<select name="mode">
						<c:forEach items="${MODE_MAP}" var="t">
							<option value="${t.key }" <c:if test="${t.key eq menu.mode}">selected="selected"</c:if>>${t.value }</option>
						</c:forEach>
					</select>
				</div>
			</div>

			<c:if test="${isDeveloper}">
				<div class="layui-form-item">
					<label class="layui-form-label layui-form-required">菜单类型</label>
					<div class="layui-input-inline">
						<select name="type">
							<c:forEach items="${typeMap}" var="t">
								<option value="${t.key }" <c:if test="${t.key eq menu.type}">selected="selected"</c:if>>${t.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
			</c:if>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-primary layui-border-blue" lay-submit="" lay-filter="sub">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary layui-border-blue">重置</button>
					<button type="button" class="layui-btn layui-btn-primary layui-border-red" onclick="closed()">关闭</button>
				</div>
			</div>
		</form>
  	  </div>
	</div>
</div>
<script src="${pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${FILE_VERSION}"></script>
<script src="${pageContext.request.contextPath}/static/js/common/coreTree-2.0.0.js?v=${FILE_VERSION}"></script>
<script>
	layui.config({
		base: getContextPath() + '/static/layuiadmin/' //静态资源所在路径
	}).extend({
		index: 'lib/index' //主入口模块
	}).use(['form'], function() {
	var form = layui.form;
	form.on('submit(sub)', function(data){
		return saveOrUpdate($("#id").val(),"/sys/menu",data);
	});
});


function selectMenu(){
	var url  = getContextPath() +  "/sys/menu/setMenu?queryTop=true";
	layer.open({
		title : "选择菜单",
		type: 2,
		area: ['500px', '90%'],
		anim: 2,
		content: [url, 'yes']
	});
}

function setMenuValue(id,name){
	$("#parentId").val(id);
	$("#parentName").val(name);
	layer.closeAll();
}
</script>
</body>
</html>